/**
 * 
 */
package mdb.com.vn.web.view;

import java.io.Serializable;
import java.util.List;

import javax.faces.model.ListDataModel;

import mdb.com.vn.model.SME;

import org.primefaces.model.SelectableDataModel;

/**
 * @author tu.dod
 *
 */
public class SMEDataModel extends ListDataModel<SME> implements SelectableDataModel<SME>,Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public SMEDataModel(){
		
	}
	public SMEDataModel(List<SME> smes){
		super(smes);
	}
	@SuppressWarnings("unchecked")
	@Override
	public SME getRowData(String rowKey) {
		List<SME> smes = (List<SME>) getWrappedData();
		for (SME sme : smes) {
			if(String.valueOf(sme.getId()).equals(rowKey)){
				return sme;
			}
		}
		return null;
	}

	@Override
	public Object getRowKey(SME sme) {
		// TODO Auto-generated method stub
		return sme.getId();
	}

}
